package com.pipi.biyesheji.dao.manager.impl;

import com.pipi.biyesheji.dao.support.PageResult;
import com.pipi.biyesheji.dao.model.CategoryDO;
import com.pipi.biyesheji.dao.query.CategoryQuery;
import com.pipi.biyesheji.dao.mapper.ext.CategoryExtMapper;
import com.pipi.biyesheji.dao.manager.CategoryManager;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;


/**
 * Manager for Category.
 */

@Component
public class CategoryManagerImpl implements CategoryManager{

    
    @Autowired
    protected CategoryExtMapper categoryExtMapper;
    /**
     * query count by query condition.
     */
    @Override
    public int countByQuery(CategoryQuery query){
        return categoryExtMapper.countByQuery(query);
    }

    /**
     * delete by query condition.
     */
    @Override
    public int deleteByQuery(CategoryQuery query){
        return categoryExtMapper.deleteByQuery(query);
    }

    /**
     * delete by primary key.
     */
    @Override
    public int deleteByPrimaryKey(Long id){
        return categoryExtMapper.deleteByPrimaryKey(id);
    }

    /**
     * insert selective.
     */
    @Override
    public long insertSelective(CategoryDO record){
        return categoryExtMapper.insertSelective(record);
    }

    /**
     * select by query condition.
     */
    @Override
    public List<CategoryDO> selectByQuery(CategoryQuery query){
        return categoryExtMapper.selectByQuery(query);
    }

    /**
     * select by query condition with page.
    */
    @Override
    public PageResult<CategoryDO> selectByQueryWithPage(CategoryQuery query) {
        PageResult<CategoryDO> result = new PageResult<CategoryDO>();
        result.setPageSize(query.getPageSize());
        result.setPageNo(query.getPageNo());
        result.setTotalCount(this.countByQuery(query));
        result.setResult(this.selectByQuery(query));
        return result;
    }

    /**
     * select by primary key.
     */
    @Override
    public CategoryDO selectByPrimaryKey(Long id){
        return categoryExtMapper.selectByPrimaryKey(id);
    }

    /**
     * update by query condition selective.
     */
    @Override
    public int updateByQuerySelective( CategoryDO record,  CategoryQuery query){
        return categoryExtMapper.updateByQuerySelective(record,  query);
    }

    /**
     * update by query condition.
     */
    @Override
    public int updateByQuery( CategoryDO record,  CategoryQuery query){

        return categoryExtMapper.updateByQuery(record, query);
    }

    /**
     * update by primary key selective.
     */
    @Override
    public int updateByPrimaryKeySelective(CategoryDO record){
        return categoryExtMapper.updateByPrimaryKeySelective(record);
    }
}